九转馒头 09:08:11
onLoad () {
      console.log('出发了load事件')

      // 先让页码值加一
      this.page += 1
      this.initSearchResult()
      // this.initSearchList()
    }
九转馒头 09:08:46
<template>
  <div class="search-result-container">
    <!-- 点击实现后退效果 -->
    <van-nav-bar
      title="搜索结果"
      left-arrow
      @click-left="$router.back()"
      fixed
    />
    <div>通过路由携带的参数是：</div>
    <div>{{ kw }}</div>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
      :immediate-check="false"
    >
      <!-- 循环渲染文章的Item -->
      <ArtItem
        v-for="item in artList"
        :key="item.art_id"
        :article="item"
        :closable="false"
      ></ArtItem>
    </van-list>
  </div>
</template>

<script>
// 按需导入 API 方法
import { getSuggResultAPI } from '@/api/searchAPI.js'

// 导入文章的Item组件
import ArtItem from '@/components/ArtItem/ArtItem.vue'

export default {
  name: 'SearchResult',
  props: ['kw'],
  data () {
    return {
      page: 1,
      artList: [],

      // 是否正在进行上拉加载的数据请求
      loading: false,
      // 所有数据是否已经加载完毕
      finished: false

    }
  },
  created () {
    this.initSearchResult()
  },
  methods: {
    async initSearchResult () {
      const { data: res } = await getSuggResultAPI(this.kw, this.page)
      if (res.message === 'OK') {
        // this.artList = res.data.results
        this.artList = [...this.artList, ...res.data.results]
        this.loading = false
        if (res.data.results.length === 0) {
          this.finished = true
        }
      }
    },
    onLoad () {
      console.log('出发了load事件')

      // 先让页码值加一
      this.page += 1
      this.initSearchResult()
      // this.initSearchList()
    }
  },
  components: {
    ArtItem
  }

}
</script>

<style lang="less" scoped>
.search-result-container {
  padding-top: 46px;
}
</style>
